<tr class="detalle_row">
  <% fields_for "factura[detalle_attributes][]", detalle do |f| %>
    <td><%= text_field(:captura, :clave, :size => 6, :index => nil) %></td>
    <td>
      <div id="productos">
        <%= f.collection_select(:producto_id, @productos, :id, :descripcion, {}, {:index => nil}) %>
      </div>
    </td>
    <td><%= f.text_field(:unidades, :size => 5, :index => nil) %></td>
    <% if detalle.new_record? %>
      <td><%= link_to_function "Quitar", "$(this).up('.detalle_row').remove()" %></td>  
    <% else %>
      <td><%= link_to_function "Quitar", "mark_for_destroy(this)" %></td>  
      <%= f.hidden_field(:id, :index => nil) %>
      <%= f.hidden_field(:should_destroy, :index => nil, :class => 'should_destroy') %>
  <% end %>
<% end %>
<%= observe_field 'captura_clave', :url => {:action => 'on_clave'}, :update => 'productos', :with => 'clave' %>
</tr>